import React from "react"
import './MyHeader.css'
// import {connect} from "react-redux"
import {withRouter} from 'react-router-dom'

// asserts
import defaultAvatarUrl from '../../../../res/images/web/shared/touxiang@2x.png'

// components
import UnLoginHeader from "./UnLoginHeader/UnLoginHeader"
import LoginHeader from "./LoginHeader/LoginHeader"
import constants from "../../../../utils/constants";


const MyHeader = (props) => {
    const {isLogin, userDetail, history,} = props
    let {Iconurl,} = userDetail
    // const isVip = Vip > 0
    if (!Iconurl.startsWith('http')) {
        Iconurl = defaultAvatarUrl
    }

    const avatarUrl = isLogin ? Iconurl : defaultAvatarUrl

    const template = isLogin
        ? <LoginHeader
            avatarUrl={avatarUrl}
            history={history}
            userDetail={userDetail}
        />
        : <UnLoginHeader
            avatarUrl={avatarUrl}
            history={history}
        />

    return (
        <div className='my-header-container' style={{background: constants.themeColor,}}>
            {template}
        </div>
    )
}

export default withRouter(MyHeader)
